home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java Primer Plus
/
Java Primer Plus (Waite Group Proess)(1996).iso
/
chapter8
/
calcfuture.java
< prev
next >
Wrap
Text File
|
1995-12-31
|
496b
|
22 lines
/* Calculate future value */
class calcfuture {
public static void main(String args[]) {
System.out.println(calc_future(0.0F,0.08f,4));
}
/* method doing the work */
public static float calc_future (float principal,float interest,int years) {
if (principal == 0.0) return 0.0f;
float the_answer = principal;
for (int y=0; y<years; ++y)
the_answer += the_answer * interest;
return the_answer;
}
}